$(function () {
    var dateTime;
    //Date range picker with time picker
    $('#reservationtime').daterangepicker(
        {
            timePicker: true,
            format: "YYYY-MM-DD HH:mm:ss",
            startDate: moment(),
            minDate: moment(),
            singleDatePicker: true
        },
        function (start, end) {
            dateTime = start.format("YYYY-MM-DD HH:mm:ss");
            $(".timesel").show();
            $(".timesel").children("p").text(start.format("YYYY-MM-DD HH:mm:ss"));
        }
    );
    $("#func_createAc").attr("class", "active");
    $(".btn-flat").click(function () {
        // action goes here!!
        $.ajax({
            url: "/activity/createActivity",
            //传送请求数据
            data: {startTime: dateTime},
            success: function (result) {
                console.info(result);
                if (result) {
                    addMessage("success", "操作成功");
                    setTimeout(" window.location.href = \"/activity/index\"", 2000);
                }
            }
        });
    });
    var addMessage = function (type, message) {
        $("#message_content").html("");
        $("#message_content").removeClass("message_success");
        $("#message_content").removeClass("message_error");
        if (message != null && message != '') {
            if (type == 'success') {
                $("#message_content").addClass("message_success");
            } else {
                $("#message_content").addClass("message_error");
            }
            $("#message_content").html(message);
            $("#message_info").fadeIn();
            setTimeout(function () {
                $("#message_info").fadeOut();
            }, 2000);
        }
        ;
    };
})